<?php
//本插件包括一键上下架、按分类一键上下架以及29同系统一键对接
switch ($act) {
   case 'yjflxj':
	    $a=$DB->query("select * from qingka_wangke_fenlei where status=0");
	    $count1=$DB->count("select count(*) from qingka_wangke_fenlei where status=0");
	    while($row=$DB->fetch($a)){
	        $b=$DB->query("select * from qingka_wangke_class where fenlei='{$row['id']}' ");
	        while($res=$DB->fetch($b)){
	            $DB->query("update qingka_wangke_class set status='0' where cid={$res['cid']} ");
	        }
        }
        jsonReturn(1,"已下架{$count1}个分类内的全部项目");
        //exit('{"code":1,"msg":"已下架$count1个分类内的全部项目"}');
	break;
	case 'yjflsj':
	    $a=$DB->query("select * from qingka_wangke_fenlei where status=1");
	    $count1=$DB->count("select count(*) from qingka_wangke_fenlei where status=1");
	    while($row=$DB->fetch($a)){
	        $b=$DB->query("select * from qingka_wangke_class where fenlei='{$row['id']}' ");
	        while($res=$DB->fetch($b)){
	            $DB->query("update qingka_wangke_class set status='1' where cid={$res['cid']} ");
	        }
        }
        jsonReturn(1,"已上架{$count1}个分类内的全部项目");
        //exit('{"code":1,"msg":"已下架$count1个分类内的全部项目"}');
	break;
	case 'yjsj':
	    $b=$DB->query("select * from qingka_wangke_class where 1=1 ");
	    $count1=$DB->count("select count(*) from qingka_wangke_class where 1=1");
	    while($res=$DB->fetch($b)){
	        $DB->query("update qingka_wangke_class set status='1' where cid={$res['cid']} ");
	    }
        jsonReturn(1,"已上架{$count1}个项目");
	break;
	case 'yjxj':
	    $b=$DB->query("select * from qingka_wangke_class where 1=1 ");
	    $count1=$DB->count("select count(*) from qingka_wangke_class where 1=1");
	    while($res=$DB->fetch($b)){
	        $DB->query("update qingka_wangke_class set status='0' where cid={$res['cid']} ");
	    }
        jsonReturn(1,"已下架{$count1}个项目");
	break;
	case 'yjdj':
            if($userrow['uid']==1){
	    $hid=trim(strip_tags(daddslashes($_GET['hid'])));
	    $a = $DB->get_row("select * from qingka_wangke_huoyuan where hid='{$hid}' ");
	    $data = array("uid" => $a["user"], "key" => $a["pass"]);
	    $er_url = "{$a["url"]}/api.php?act=getclass";
	    $result = get_url($er_url, $data);
	    $result1 = json_decode($result, true);
	    $DB->query("insert into qingka_wangke_fenlei (sort,name,status,time) values ('0','{$a["name"]}','1',NOW())");
	    $b = $DB->get_row("select * from qingka_wangke_fenlei where name='{$a["name"]}' ORDER BY id DESC LIMIT 0,1");
	    $data = $result1["data"];
        foreach($data as $k => $value){
            $DB->query("insert into qingka_wangke_class (name,getnoun,noun,fenlei,queryplat,docking) values ('{$value['name']}','{$value['cid']}','{$value['cid']}','{$b["id"]}','$hid','$hid')");
        }
	    jsonReturn(1,"已上架{$a["name"]}的全部项目，共计{$k}个，并自动新建分类到【{$b["name"]}】中");
            }
	break;
}
?>